﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace Sha1
{
    class Program
    {
        static void Main(string[] args)
        {
           // byte[] data = new byte[1024];


    
            // This is one implementation of the abstract class SHA1.

            using (FileStream inFile = new FileStream("input.bin", FileMode.Open),
                outFile = new FileStream("output.bin", FileMode.OpenOrCreate))
            {
                byte[] buf = new byte[inFile.Length];
                int offSet = 0;
                while (true)
                {

                    int bytesRead = inFile.Read(buf, offSet, (int)(inFile.Length-offSet));
                    if (bytesRead == 0)
                    {
                        break;
                    }
                    offSet += bytesRead;
                }
                SHA1 sha = new SHA1CryptoServiceProvider();
                byte[] result = sha.ComputeHash(buf);
                outFile.Write(result, 0, result.Length);
            }

        }
    }
}
